<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>星调查问卷系统</title>

<!-- BOOTSTRAP STYLES-->
<link href="css/bootstrap.css" rel="stylesheet" />
<!-- FONTAWESOME STYLES-->
<link href="css/font-awesome.css" rel="stylesheet" />
   <!--CUSTOM BASIC STYLES-->
<link href="css/basic.css" rel="stylesheet" />
<!--CUSTOM MAIN STYLES-->
<link href="css/custom.css" rel="stylesheet" />
<!-- GOOGLE FONTS-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />

<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script>
</script>
</head>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="home.jsp">星调查问卷系统</a>
        </div>

    </nav>
    <!-- /. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">
                <li>
                    <div class="user-img-div">
                            <c:if test="${sessionScope.users.user_photo==null }">
                             <img src="images/user.png" class="img-thumbnail" />
                        </c:if> 
                        <c:if test="${sessionScope.users.user_photo!=null }">
                                <img src="${pageContext.request.contextPath}/images/user/${sessionScope.users.user_name}.${sessionScope.users.user_photo}" class="img-thumbnail">
                        </c:if> 
                        <div class="inner-text">
                            <span>${sessionScope.users.user_name }</span>
                        <br />
                            <small>
                                    用户级别：
                                    <c:if test="${sessionScope.users.user_root==1 }">
                                        管理员
                                </c:if> 
                                <c:if test="${sessionScope.users.user_root==0}">
                                        普通用户
                                </c:if> 
                                <form action="${pageContext.request.contextPath}/outLogin.do">
                                    <table>
                                        <tr>
                                            <td><input type="submit" value="退出登录" class="form-control input-sm"></td>
                                        </tr>
                                    </table>
                                </form>
                            </small>
                        </div>
                    </div>
                </li>
                
                <li>
                    <a  href="${pageContext.request.contextPath}/home.do"><i class="fa fa-dashboard "></i>我的问卷</a>
                </li>
              
                <li>
                    <a class="active-menu" href="${pageContext.request.contextPath}/newSurvey.do"><i class="fa fa-flash "></i>新建问卷 </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/allSurvey.do"><i class="fa fa-flash "></i>所有问卷</a>           
                </li>
                <c:if test="${sessionScope.users.user_root==1 }">
	                <li>
	                    <a href="${pageContext.request.contextPath}/adminView.do"><i class="fa fa-flash "></i>用户管理</a>           
	                </li>
                </c:if>
            </ul>
        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-head-line">添加问题</h1>
                </div>
            </div>
            <!-- /. ROW  -->
            <div class="row">
                    <div class="main-box ">
                    <form id="newQuestion"  action="${pageContext.request.contextPath}/newQuestion.do" method="post" onsubmit="return nulls()"> 
                        <div class="form-group">
                       	 	<input type="hidden" class="form-control" name="survey_id" id="survey_id" value="${survey.survey_id }">
                            <label for="survey_questionName">题目内容</label> 
                            <input type="text" class="form-control" name="survey_questionName" id="survey_questionName" datatype="*" nullmsg="请输入问题名！">
                        </div>
                        <div class="form-group">
                            <label for="survey_questionType">题目类型</label> 
                            <input class="btn btn-default" type="radio" id="single">
                            <label>单选</label> 
                            <input class="btn btn-default" type="radio" id="answer">
                            <label>开放题</label> 
                        </div>
                        <div class="form-group">
                        <button type="button" class="btn btn-default" id="addQuestion">添加</button>
                        <div class="form-group"><input type="submit" class="form-control" name="Action" id="saveQuestion" value="保存问卷"></div>
                        </div>
                    </form>
                </div>
            </div>
            <!-- /. ROW  -->

        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
  <!-- /. FOOTER  -->
<!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
<!-- JQUERY SCRIPTS -->
<script src="js/jquery-1.10.2.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="js/bootstrap.min.js"></script>
<!-- METISMENU SCRIPTS -->
<script src="js/jquery.metisMenu.js"></script>
   <!-- CUSTOM SCRIPTS -->
<script src="js/custom.js"></script>

<script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="js/locales/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>
<script src="js/Validform_v5.3.2_min.js"></script>

<script>
        $(document).ready(function(){
       	 	$('#newQuestion').Validform({
				tiptype:3, 
			});
        	
            $('#addQuestion').click(function(){
                if($('input:radio:checked').attr('id')=="single"){
                    //选择类型后锁定类型
                    $('input:radio').attr("disabled",true);
                    var questionType = '<div class="form-group"><input type="hidden" class="form-control" name="survey_questionType" id="survey_questionType" value="1"></div>';
                    var singleA ='<div class="form-group"><input type="radio" name="slecet" class="btn btn-default"><input type="text" class="form-control" name="survey_questionSingleA" id="survey_questionSingleA" datatype="*" nullmsg="请输入选项！"></div>';
                    var singleB ='<div class="form-group"><input type="radio" name="slecet" class="btn btn-default"><input type="text" class="form-control" name="survey_questionSingleB" id="survey_questionSingleB" datatype="*" nullmsg="请输入选项！"></div>';
                    var singleC ='<div class="form-group"><input type="radio" name="slecet" class="btn btn-default"><input type="text" class="form-control" name="survey_questionSingleC" id="survey_questionSingleC" datatype="*" nullmsg="请输入选项！"></div>';
                    var continues = '<div class="form-group"><input type="submit" class="form-control" name="Action" value="继续添加"></div>';
                    var ends = '<div class="form-group"><input type="submit" class="form-control" name="Action" value="保存问卷"></div>';
                    $('#addQuestion').after(questionType+singleA+singleB+singleC+continues);
                }

                if($('input:radio:checked').attr('id')=="answer"){
                    //选择类型后锁定类型
                    $('input:radio').attr("disabled",true);
                    var questionType = '<div class="form-group"><input type="hidden" class="form-control" name="survey_questionType" id="survey_questionType" value="2"></div>';
                    var answers ='<div class="form-group"><label>简答题题目</label> <input type="text" class="form-control" name="survey_questionAnswer" id="survey_questionAnswer" datatype="*" nullmsg="请输入选项！"></div>';
                    var continues = '<div class="form-group"><input type="submit" class="form-control" name="Action" value="继续添加"></div>';
                    var ends = '<div class="form-group"><input type="submit" class="form-control" name="Action" value="保存问卷"></div>';
                    $('#addQuestion').after(questionType+answers+continues);
                }
            })

            function nulls(){
                $('input:text').each(function(i,obj){
                    if(obj.value==""){
                        console.log("有未填项");
                        return false
                    }
                    return true;
                })
            }
        })
    
</script>
</body>
</html>